local joy__huanhua = fk.CreateSkill {

  name = "joy__huanhua",

  tags = {  },

}



joy__huanhua:addEffect("active", {
  name = "joy__huanhua",
  card_num = 2,
  target_num = 0,
  prompt = "#joy__huanhua-prompt",
  card_filter = function(self, player, to_select, selected)
    if not table.contains(player.player_cards[Player.Hand], to_select) then return false end
    local card = Fk:getCardById(to_select)
    if #selected == 0 then
      return card:getMark("@@joy__huanshu_card") == 1 and card:getMark("@@joy__huanhua_card-inhand") == 0
    elseif #selected == 1 then
      return Fk:getCardById(selected[1]):getMark("@@joy__huanshu_card") == 1
       and card:getMark("@@joy__huanhua_tar-inhand") == 0
      and (card:getMark("@@joy__huanshu_card") == 0 or player:getMark("@joy__huanjing-turn") > 0)
    end
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(joy__huanhua.name, Player.HistoryTurn) < (2 + player:getMark("@joy__huanjing-turn"))
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local huan_card = Fk:getCardById(effect.cards[1])
    local tar_card = Fk:getCardById(effect.cards[2])
    local get = huan_card.suit == tar_card.suit
    room:setCardMark(tar_card, "@@joy__huanhua_tar-inhand", 1)
    Fk:filterCard(huan_card.id, player)
    room:delay(300)
    room:moveCardTo(huan_card, Card.Void, nil, fk.ReasonJustMove, joy__huanhua.name)
    HuanHuaCard(player,tar_card.name, tar_card.suit, tar_card.number,joy__huanhua.name)
    if get then
      GetHuanCard (player, 1, joy__huanhua.name)
    end
  end,
})

return joy__huanhua